<template>
  <!-- treeDefaultExpandAll -->

  <a-select style="width: 100%" @change="handleProvinceChange">
    <a-select-option v-for="item in list" :key="item.Id" :value="item.Id"> </a-select-option>
  </a-select>
</template>
<script>
export default {
  props: {
    placeholder: { type: String, required: false, default: '类型' },
    value: { type: String, required: false }
  },
  data() {
    return {
      list: [],
      curValue: '',
      data: [],
      TreeData: []
    }
  },
  watch: {
    value(value) {
      //console.log(value)
      this.curValue = value
    }
  },
  created() {
    this.curValue = this.value
    // this.getEnumItem()
  },
  methods: {
    getDataList() {
      this.loading = true

      this.$http.post('/QuotationManagement/Quot_PriceListMain/GetDataList').then(resJson => {
        this.list = resJson.Data
      })
    },
    onLoadData(treeNode) {
      //console.log(treeNode)
      //console.log(treeNode.dataRef)
      const thisObj = this
      const { Id } = treeNode.dataRef
      //console.log(Id)
      return new Promise((resolve, reject) => {
        thisObj.$http.post('/QuotationManagement/Quot_PriceListMain/GetDataList' + Id, {}).then(resJson => {
          var data = resJson.Data

          this.$set(treeNode.dataRef, 'children', data)

          //console.log(treeNode.dataRef)
          resolve()
        })
      })
    },
    genTreeNode(parentId, isLeaf = false) {
      const random = Math.random()
        .toString(36)
        .substring(2, 6)
      return {
        id: random,
        pId: parentId,
        value: random,
        title: isLeaf ? 'Tree Node' : 'Expand to load',
        isLeaf
      }
    },
    // async getEnumItem(id = '') {
    //   await this.$http.post('/Clt/Clt_Product/GetDataList' + id).then(resJson => {
    //     this.TreeData = resJson.Data
    //     // this.data.forEach(item => {
    //     //   // item.children = null
    //     //   this.TreeData.push(item)
    //     // })
    //   })
    // },
    handleSelected(val) {
      //console.log(val)
      this.$emit('input', val)
    }
  }
}
</script>
